#ifndef _BASE_MINING_H_
#define _BASE_MINING_H_
/****************************************************************************
*				W A R N I N G
*				~~~~~~~~~~~~~
*			    Copyright (c) 1999
*			    NetScout Systems Inc.
*			    Chelmsford, MA 01824
*			    All Rights Reserved
*
* This software is part of Licensed material, which is the property of
* NetScout Systems Inc.  Unauthorized use, duplication or distribution
* is strictly prohibited by Federal law. No title to and ownership of
* this software is hereby transferred.
****************************************************************************/
/****************************************************************************
Module Name: basemining.h
Engineer   : Mahesh Rajmane
Description: Base class for mining
Revision History:
--------------------------------------------------------------------------
Vers	Date			Who	Why
--------------------------------------------------------------------------
001	08 Mar 2011		MDR	Module Created
--------------------------------------------------------------------------
****************************************************************************/

#include "platdep.h"
#include "miningio.h"

using namespace std;

enum MINEOPTYPE { ASCIIOP, BINARYOP, TLVOP };

// all the mining operators supported

/* ++
This is base mining class.  Mining for individual store is derived from this.
++ */
class BaseMining{
public:
	//Function for initializing tables
	static void init();

	// gives the mining instance for store.
	static BaseMining *getMiningInstance(const char *store); 

	// to verify if name exists in store
	virtual int verifyName(char *name) = 0; 

	virtual char* verify(struct object_chain *node, bool proj, char *funcref) = 0;
	
	//To obtain the datatype of the column for verification purposes
	
	virtual int getType(char *name) = 0;
	// projection, output terms
	virtual int setProjection(char *name, char *funcref) = 0; 
	virtual void setProjectionsAll() = 0;
	virtual void displayProjection() = 0;
	// selection
	// selects the nanosecond start and end time
	virtual bool setTime(N64 startTime, N64 endTime) { mStartTime = startTime; mEndTime = endTime; return true; }
	
	// functions for filtering
	/*
	take name operator and value and generates internal miningNode. Returns 
	pointer to  miningNode.
	*/
	virtual void *setFilter1(char *name, MINEOPERATOR op, char *value, int total, int counter ) = 0;
	virtual void *setFilter2(void *node, MINEOPERATOR op, char *value, int total, int counter) = 0;
	virtual void *setFilter3(char *name, MINEOPERATOR op, void *node, int total,  int counter ) = 0;
	virtual void *setFilter4(void *node1, MINEOPERATOR op, void *node2, int total, int counter) = 0;
	
	// functions for configuration
	void setIP(N32 ip) { mIP = ip; }
	void setIfn(N32 ifn) { mIfn = ifn; }

	// output should be printed ascii
	bool setAscii() { mOType = ASCIIOP; return 1; }
	// output should be binary
	bool setBinary() { mOType = BINARYOP; return 1; }
	// TLV output is required
	bool setTLV() { mOType = TLVOP; return 1; }

	// set output methods
	void setOutput(MiningIO *output) { mOP = output; }

	//Function for cleaning and destroying the tables
	static void cleanUp();
	virtual ~BaseMining();
	// execution of tree of miningNodes
	//virtual bool startMining() = 0;

protected:
	N32 mIP;
	N32 mIfn;
	N64 mStartTime;
	N64 mEndTime;
	MINEOPTYPE mOType;
	MiningIO *mOP;
private:
	static char *tnames[2];
        static BaseMining *tables[2];
};

#endif
